#pragma once

#ifndef COMMON_H
#define COMMON_H

#define IGNORE_PARAM(x) ((void *)x)

#include <cstdio>
#include <cstddef>

inline bool LoadRomFile(const char* const filename, unsigned char* const buffer, const size_t expectedSize)
{
	FILE * file;
	file = fopen(filename, "rb");

	if (!file)
	{
		printf("File %s not found\n", filename);
		return false;
	}

	fseek(file, 0, SEEK_END);
	size_t fileSize = ftell(file);

	if(expectedSize != fileSize)
	{
		printf("Expected file size not match with %s file size\n", filename);
		return false;
	}

	fseek(file, 0, SEEK_SET);

	size_t result = fread(buffer, fileSize, 1, file);

	if(result != 1)
	{
		printf("Error reading %d byte from %s file\n", fileSize, filename);
		return false;
	}

	fclose(file);

	return true;
}

#endif
